package es.cazadoresmadridejos.beans.facade;

import javax.servlet.http.HttpServletRequest;

import org.directwebremoting.annotations.RemoteProxy;
import org.directwebremoting.spring.SpringCreator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.stereotype.Service;

import es.cazadoresmadridejos.beans.service.mail.MailService;
import es.cazadoresmadridejos.beans.service.mail.MailService.MailSubject;

@Service
@RemoteProxy(name="mailFacade",creator=SpringCreator.class)
public class MailFacade {
	private static final String THE_MAIL_WAS_SENT_SUCCESSFULLY = "THE_MAIL_WAS_SENT_SUCCESSFULLY";
	
	@Autowired private MailService mailService;
	@Autowired private MessageSource messageSource;
	
	public String notifyNewAdviced(Long advicedId, HttpServletRequest request){
		mailService.sendMail("alfonso_ash@hotmail.com", messageSource.getMessage(MailSubject.NEW_ADVICED.name(),null,request.getLocale()), "Estimado Socio,\n\nLa sociedad de cazadores de Madridejos le informa de que hay avisos nuevos en la página WEB de la Sociedad.\n\nUn saludo");
		
		return messageSource.getMessage(THE_MAIL_WAS_SENT_SUCCESSFULLY,null, request.getLocale());
	}
}
